package com.example.mywechat;


import androidx.fragment.app.Fragment;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.recyclerview.widget.ItemTouchHelper;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import java.util.ArrayList;
import java.util.List;

/**
 * A simple {@link Fragment} subclass.
 */
public class weixinFragment extends Fragment {
    private RecyclerView recyclerView;
    private List<String> myList = new ArrayList<>();
    private Context context;
    private weixin_adapter adapter;

    public weixinFragment() {
        // Required empty public constructor
    }

    private void initData(){
        myList.add("DWG");
        myList.add("SN");
        myList.add("TES");
        myList.add("G2");
        myList.add("JDG");
        myList.add("FNC");
        myList.add("GEN.G");
        myList.add("DRX");
        myList.add("UOL");
        myList.add("FLY");
        myList.add("LGD");
        myList.add("TSM");
        myList.add("PSG");
        myList.add("RGE");
        myList.add("TL");
        myList.add("MCX");
    }

    private void initView1(){
        context=this.getActivity();
        adapter=new weixin_adapter(context,myList);

        ItemTouchHelper.Callback callback = new SwipeItemTouchHelper(adapter);
        ItemTouchHelper touchHelper = new ItemTouchHelper(callback);
        touchHelper.attachToRecyclerView(recyclerView);

        LinearLayoutManager manager=new LinearLayoutManager(context);
        manager.setOrientation(LinearLayoutManager.VERTICAL);

        recyclerView.setAdapter(adapter);
        recyclerView.setLayoutManager(manager);
        recyclerView.setHasFixedSize(true);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View view = inflater.inflate(R.layout.tab01, container, false);
        recyclerView=view.findViewById(R.id.rcv1);
        initData();
        initView1();

        return view;
    }
}
